Ubuntu 16.04
Sponsored Link

Configure NFS Client (Ubuntu)
2016/04/23
 
Configure NFS Client. This example is based on the environment below.
+----------------------+          |          +----------------------+
| [    NFS Server    ] |10.0.0.30 | 10.0.0.31| [    NFS Client    ] |
|     dlp.srv.world    +----------+----------+    client.srv.world  |
|                      |                     |                      |
+----------------------+                     +----------------------+

[1] Configure NFS Client.
root@client:~#
apt-get -y install nfs-common
root@client:~#
vi /etc/idmapd.conf
# line 6: uncomment and change to your domain name

Domain =
srv.world
root@client:~#
mount -t nfs dlp.srv.world:/home /home

root@client:~#
df -hT

Filesystem                  Type      Size  Used Avail Use% Mounted on
udev                        devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                       tmpfs     396M  5.6M  390M   2% /run
/dev/mapper/ubuntu--vg-root ext4       25G  1.4G   23G   6% /
tmpfs                       tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                       tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs                       tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1                   ext2      472M   55M  393M  13% /boot
tmpfs                       tmpfs     100K     0  100K   0% /run/lxcfs/controllers
tmpfs                       tmpfs     396M     0  396M   0% /run/user/0
dlp.srv.world:/home      nfs4       25G  1.4G   23G   6% /home
# /home from NFS server is mounted
[2] Configure NFS mounting on fstab to mount it when the system boot.
root@client:~#
vi /etc/fstab
# add like follows

dlp.srv.world:/home   /home  nfs     defaults        0       0
[3] Configure auto-mounting.
For example, set NFS directory on /mntdir.
root@client:~#
apt-get -y install autofs
root@client:~#
vi /etc/auto.master
# add follows to the end

/-    /etc/auto.mount

root@client:~#
vi /etc/auto.mount
# create new : [mount point] [option] [location]

/mntdir -fstype=nfs,rw  dlp.srv.world:/home

root@client:~#
mkdir /mntdir

root@client:~#
systemctl restart autofs
# move to the mount point to verify it works normally

root@client:~#
cd /mntdir

root@client:/mntdir#
total 12
drwxr-xr-x  3 root   root   4096 Apr 22 11:45 ./
drwxr-xr-x 24 root   root   4096 Apr 25 09:42 ../
drwxr-xr-x  4 ubuntu ubuntu 4096 Apr 22 15:46 ubuntu/

root@client:/mntdir#
cat /proc/mounts | grep mntdir

/etc/auto.mount /mntdir autofs rw,relatime,fd=6,pgrp=4209,timeout=300,minproto=5,maxproto=5,direct 0 0
dlp.srv.world:/home /mntdir nfs4 rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,
port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.0.0.31,local_lock=none,addr=10.0.0.30 0 0
 
Tweet